function endtime() {
    var time = $("#timehour").val();
    if (time != '选择出发时间') {

        $("#endtime").html("10:00");
    }
}

function addtrainnum() {
    var msg = "您真的确定要添加车次吗？\n\n请确认！";
    if (confirm(msg) == true) {
        var trainid = $("#trainid").val();
        var date = $("#LAY_demorange_s").val();
        var time = $("#timehour").html();
        var myDate = new Date();
        var today = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate();
        var month = myDate.getMonth() + 1;
        var year = myDate.getFullYear();
        var day = myDate.getDate();
        var isflag = date.split("-");
        if (date == "") {
            alert("请添加日期");
            return;
        }
        if (parseInt(isflag[0]) <= year) {
            if (parseInt(isflag[1]) < month) {
                alert("请添加" + today + "以后的车次");
                return;
            }
            if (parseInt(isflag[1]) == month) {
                if (parseInt(isflag[2]) < day) {
                    alert("请添加" + today + "以后的车次");
                    return;
                }
            }
        }
        $.ajax({
            type: "post",
            url: "train/addtrainnum/" + trainid + "/" + date + "/" + time,
            contentType: "application/jspn;charset=utf-8",
            success: function (data) {
                if (data =='0') {
                    alert("车次添加成功！");
                }
                if (data=='2') {
                    alert("车次添加失败！");
                }
                if (data=='1') {
                    alert("该日期车次已存在！");
                }

            }, error: function (data) {
                alert("车次添加失败！");
            }
        });


    }
}